Skip to content

test(cli): keep polling while the pre-run PID file is still being written - #4

Merged
MakFly merged 1 commit into
mainfrom
fix/prerun-grandchild-pid-race
Dec 2, 2026
Merged

MakFly merged 1 commit into
mainfrom
fix/prerun-grandchild-pid-race

Conversation

@MakFly

@MakFly MakFly commented Dec 2, 2026

Copy link
Copy Markdown
Contributor

Why

TestDefaultPreRunCommandKillsGrandchildOnDeadline failed on main CI (run for 4a0df0c) with grandchild did not start after 0.01s, while the same code passed on the pull request.

Cause

The helper process writes the grandchild PID with os.WriteFile, which creates the file before writing it. A poll that landed between the two read an empty file, parsed PID 0 and stopped polling.

Fix

The polling loop keeps waiting until the file holds a valid PID. Test only, no product code.

Checks

  • Reproduced by widening the create/write window in the helper (200 ms): the test failed with the CI message, then passed with the fix. The probe was removed before commit.
  • gofmt -l . (empty), go vet ./..., go test -count=1 ./... pass; the fixed test passes 10 times in a row.

🤖 Generated with Claude Code

…tten

TestDefaultPreRunCommandKillsGrandchildOnDeadline failed on main CI
(run for 4a0df0c) with "grandchild did not start" after 0.01s. The helper
writes the grandchild PID with os.WriteFile, which creates the file before
writing it; a poll that landed between the two read an empty file, parsed
PID 0 and stopped polling. Reproduced by widening that window in the helper.
The loop now waits until the file holds a valid PID.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@MakFly
MakFly merged commit cfdf01c into main Dec 2, 2026
3 checks passed
@MakFly
MakFly deleted the fix/prerun-grandchild-pid-race branch December 2, 2026 00:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant